{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/containers/GetUserDialog.tsx\",\n  _s = $RefreshSig$();\nimport React from 'react';\nimport { observer } from \"mobx-react-lite\";\nimport { Context } from \"../index\";\nimport { GetUserDialog as GetUserDialogComponent } from \"../components\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\nconst GetUserDialog = props => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [chat, setChat] = React.useState();\n  const cleanedChat = {};\n  React.useEffect(() => {\n    if (!props.selfProfile && store.getChats().items.length > 0) {\n      store.getChats().items.forEach((itemChat, indexChat) => {\n        if (!itemChat.multiChat) {\n          var _itemChat$membership;\n          (_itemChat$membership = itemChat.membership) === null || _itemChat$membership === void 0 ? void 0 : _itemChat$membership.items.forEach((itemMember, indexMember) => {\n            var _itemChat$membership2;\n            if (itemMember.usersListItem.id === props.profile.id) {\n              setChat({\n                ...chat,\n                ...itemChat\n              });\n            } else if (store.getChats().items.length === indexChat + 1 && ((_itemChat$membership2 = itemChat.membership) === null || _itemChat$membership2 === void 0 ? void 0 : _itemChat$membership2.items.length) === indexMember) {\n              setChat({});\n            }\n          });\n        }\n      });\n    } else {\n      console.log(454534);\n    }\n  }, [store.chats, store.currentDialog, props.profile]);\n  const handleOnClick = () => {\n    if (chat !== null && chat !== void 0 && chat.id) {\n      console.log(chat.id);\n    } else {\n      console.log(false);\n    }\n  };\n  if (!props.selfProfile) {\n    return /*#__PURE__*/_jsxDEV(GetUserDialogComponent, {\n      callback: handleOnClick\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 49,\n      columnNumber: 13\n    }, this);\n  } else {\n    return /*#__PURE__*/_jsxDEV(_Fragment, {}, void 0, false);\n  }\n};\n_s(GetUserDialog, \"nWtq9SaX/HZRszR+6asqbeDRYDA=\");\n_c = GetUserDialog;\nexport default _c2 = observer(GetUserDialog);\nvar _c, _c2;\n$RefreshReg$(_c, \"GetUserDialog\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","observer","Context","GetUserDialog","GetUserDialogComponent","props","store","useContext","chat","setChat","useState","cleanedChat","useEffect","selfProfile","getChats","items","length","forEach","itemChat","indexChat","multiChat","membership","itemMember","indexMember","usersListItem","id","profile","console","log","chats","currentDialog","handleOnClick"],"sources":["/data/messenger.client/src/containers/GetUserDialog.tsx"],"sourcesContent":["import React from 'react';\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../index\";\nimport {GetUserDialog as GetUserDialogComponent} from \"../components\";\nimport {UserProfileProps} from \"../models/props/UserProfileProps\";\nimport {ChatsListItem} from \"../models/response/ChatsListItem\";\n\nconst GetUserDialog: React.FC<UserProfileProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const [chat, setChat] = React.useState<ChatsListItem>();\n\n    const cleanedChat = {} as ChatsListItem;\n\n    React.useEffect(() => {\n        if (!props.selfProfile && store.getChats().items.length > 0) {\n            store.getChats().items.forEach((itemChat, indexChat) => {\n                if (!itemChat.multiChat) {\n                    itemChat.membership?.items.forEach((itemMember, indexMember) => {\n                        if (itemMember.usersListItem.id === props.profile.id) {\n                            setChat({\n                                ...chat,\n                                ...itemChat\n                            });\n                        } else if (\n                            store.getChats().items.length === indexChat + 1 &&\n                            itemChat.membership?.items.length === indexMember\n                        ) {\n                            setChat({} as ChatsListItem);\n                        }\n                    });\n                }\n            });\n        } else {\n            console.log(454534)\n        }\n\n    }, [store.chats, store.currentDialog, props.profile]);\n\n    const handleOnClick = () => {\n        if (chat?.id) {\n            console.log(chat.id)\n        } else {\n            console.log(false)\n        }\n    }\n\n    if (!props.selfProfile) {\n        return (\n            <GetUserDialogComponent callback={handleOnClick} />\n        );\n    } else {\n        return (<></>);\n    }\n}\n\nexport default observer(GetUserDialog);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,OAAO,QAAO,UA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